/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ept.controller;

import com.ept.entities.Commandeclient;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import org.primefaces.event.ToggleEvent;

/**
 *
 * @author Imen
 */
@ManagedBean(name = "monPanierController")
@ViewScoped
public class MonPanierController implements Serializable, ActionListener {

    List<Commandeclient> list;

    public List<Commandeclient> getList() {
        return list;
    }

    public void setList(List<Commandeclient> list) {
        this.list = list;
    }
    int total;

    public int getTotal() {
        total = 0;

        for (Commandeclient current : list) {
            total += current.getPrix() * current.getQuantite();
        }
        return total;
    }
    List<Commandeclient> list1;
    @EJB
    private com.ept.facade.CommandeclientFacade commandeclientFacade;

    /**
     * Creates a new instance of MonPanierController
     */
    @PostConstruct
    public String AfficherPanier() {

        LoginController loginController = (LoginController) FacesAccessor.getManagedBean("loginController");
        System.out.println("loginController.getUtilisateur().getPanier()");
        list = commandeclientFacade.findByIdPanier(loginController.getUtilisateur().getPanier());


        return "Mon_Panier.xhtml?faces-redirect=true";
    }
    
    public String Timeline() {

       


        return "Timeline.xhtml?faces-redirect=true";
    }
    
    
    
    public String Statistique() {

        


        return "ProduitStatistique.xhtml?faces-redirect=true";
    }

    public MonPanierController() {
    }

    @Override
    public void processAction(ActionEvent event) throws AbortProcessingException {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
